package org.sfx.control

import javafx.beans.property.StringProperty
import javafx.collections.ObservableList
import javafx.event.Event
import javafx.event.EventHandler
import javafx.scene.Node
import javafx.scene.control.ContextMenu
import javafx.scene.control.Menu
import javafx.scene.control.Skin
import javafx.scene.layout.StackPane
import com.sun.javafx.scene.control.skin.ContextMenuContent

class ScrollableContextMenuSkin(paramScrollableContextMenu: ScrollableContextMenu) extends Skin[ScrollableContextMenu] {
  private var popupMenu: ScrollableContextMenu = null
  private val root: StackPane = new ContextMenuContent(paramScrollableContextMenu)

  this.popupMenu = paramScrollableContextMenu

  paramScrollableContextMenu.addEventHandler(Menu.ON_SHOWN, new EventHandler[Event]() {
    override def handle(paramEvent: Event): Unit = {
      val localContextMenuContent: ContextMenuContent = popupMenu.getSkin().getNode().asInstanceOf[ContextMenuContent]
      if (localContextMenuContent == null) {
        return
      }
      localContextMenuContent.requestFocus()
    }
  })
    
  this.root.idProperty().bind(paramScrollableContextMenu.idProperty())
  this.root.styleProperty().bind(paramScrollableContextMenu.styleProperty())
  this.root.getStyleClass().addAll(paramScrollableContextMenu.getStyleClass())

  def getSkinnable(): ScrollableContextMenu = popupMenu

  def getNode(): Node = this.root

  def dispose(): Unit = {}
}
